<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity4">
<head lang="en">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <title>OAuth Server Index</title>
    <link rel="stylesheet" href="webjars/bootstrap/3.3.7/css/bootstrap.min.css" th:href="@{/webjars/bootstrap/3.3.7/css/bootstrap.css}"/>
</head>
<body>
<div class="container">
    <h1 class="page-header">OAuth Server Administration Dashboard </h1>
    <div class="row">
        <div class="col-md-12" >
            <span sec:authorize="isAuthenticated()" style="display: inline-block;">
                    <a th:href="@{/logout}">登出</a>
                </span>
        </div>
        <div class="col-md-12" >
                    <a th:href="@{/users/list}">用户管理</a>
        </div>
    </div>

    <div class="row">
        <div class="col-md-6 col-md-offset-3">
            <h2>Approvals</h2>

             <p>
                If you revoke the approval for one scope of a client all tokens for that client will be removed as well.
             </p>
            <table class="table table-bordered">
                <tr>
                    <th>Client</th>
                    <th>Scope</th>
                    <th>Expires at</th>
                    <th>Actions</th>
                </tr>
                <tr th:each="app : ${approvals}">
                    <td th:text="${app.clientId}"></td>
                    <td th:text="${app.scope}"></td>
                    <td th:text="${app.expiresAt}"></td>
                    <td th:text="${app.scope}"></td>
                    <td>
                        <form action="/approval/revoke" th:action="@{/approval/revoke}" method="POST">
                            <input type="hidden" th:name="${_csrf.parameterName}" th:value="${_csrf.token}"/>
                            <input type="hidden" name="userId" th:value="${app.userId}"/>
                            <input type="hidden" name="clientId" th:value="${app.clientId}"/>
                            <input type="hidden" name="scope" th:value="${app.scope}"/>
                            <input type="hidden" name="status" th:value="${app.status}"/>
                            <button type="submit" class="btn btn-default btn-xs">
                                <span class="glyphicon glyphicon-trash"></span>
                            </button>
                        </form>
                    </td>
                </tr>
            </table>
        </div>
    </div>
    <div class="row">
        <div class="col-md-10 col-md-offset-1" sec:authorize="hasRole('ROLE_OAUTH_ADMIN')">
            <h2>Clients</h2>
            <table class="table table-bordered">
                <tr>
                    <th>Client ID</th>
                    <th>Resource IDs</th>
                    <th>Scopes</th>
                    <th>Grant Types</th>
                    <th>Roles</th>
                    <th>Actions</th>
                </tr>
                <tr th:each="client : ${clientDetails}">
                    <td th:text="${client.clientId}"></td>
                    <td th:text="${client.resourceIds}"></td>
                    <td th:text="${client.scope}"></td>
                    <td th:text="${client.authorizedGrantTypes}"></td>
                    <td th:text="${client.authorities}"></td>
                    <td>
                        <a class="btn btn-default btn-xs" th:href="@{/clients/form?client=__${client.clientId}__}">
                            <span class="glyphicon glyphicon-edit"></span>
                        </a>
                        <a class="btn btn-default btn-xs" th:href="@{/clients/__${client.clientId}__/delete}">
                            <span class="glyphicon glyphicon-trash"></span>
                        </a>
                    </td>
                </tr>
                <tr>
                    <td colspan="6">
                        <a class="btn btn-default btn-xs pull-right" href="/clients/form" th:href="@{/clients/form}">
                            <span class="glyphicon glyphicon-plus"></span>
                        </a>
                    </td>
                </tr>
            </table>
        </div>
    </div>
</div>
</body>
</html>
